package com.bing.services;

import com.bing.HUtils;
import com.bing.entity.Note;
import org.hibernate.Session;

import java.util.List;

/**
 * Created by kaibb on 15-11-12.
 */
public class NoteServicesImpl implements NoteServices {
    @Override
    public void saveNotes(List<Note> notes) {
        if (notes.size() == 0) {
            return;
        }
        Session session = HUtils.getMySqlSession();
        session.beginTransaction();
        for (Note note : notes) {
            session.save(note);
        }
        session.flush();
        session.clear();
        session.getTransaction().commit();
        session.close();
    }
}
